1、一般情况为了方便,在使用mysql命令查询的时候会在-p后面直接加上密码,输出结果如下:
1 | mysql -u root -p12345678 -BNe "select count(*) from performance_schema.replication_group_members where MEMBER_STATE='ONLINE'" |
结果如下:
1 | mysql: [Warning] Using a password on the command line interface can be insecure. |
2、为了消除结果中的[Warning]信息,只显示查询结果,可使用环境变量存储密码的方法:
1 | export MYSQL_PWD=12345678;mysql -u root -BNe "select count(*) from performance_schema.replication_group_members where MEMBER_STATE='ONLINE'" |
结果如下:
1 | 3 |